<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise</title>
</head>
<body>
    <script>
        // Promise.resolve().then(() => {
        //     console.log(0);
        //     return Promise.resolve(4);
        // }).then((res) => {
        //     console.log(res)
        // })

        // Promise.resolve().then(() => {
        //     console.log(1);
        // }).then(() => {
        //     console.log(2);
        // }).then(() => {
        //     console.log(3);
        // }).then(() => {
        //     console.log(5);
        // }).then(() =>{
        //     console.log(6);
        // })

    </script>
    <script>
        console.log('script1');
        let promise = new Promise((resolve, reject) => {
            console.log('promise1');
            setTimeout(() => {
                console.log('timeout');
                resolve();
            }, 0);
        });
        promise.then(() => {
            console.log('ok1');
        })
    </script>
    <script>
        console.log('script2');
        let promise2 = new Promise((resolve, reject) => {
            console.log('promise2');
            resolve();
        });
        promise2.then(() => {
            console.log('ok2');
        })
        console.log('end');
    </script>
</body>
</html>